package untils

import (
	"log"
	"math/rand"
)

func TotalPrice(carType string) float64 {
	km := rand.Intn(15) //生成路程随机数
	parse := km * 3.0   //计算价格
	rate := 1.0         //初始倍率
	price := 0.0        //初始价格
	switch carType {
	case "普通轿车":
		price = 2
		rate += 1.0
	case "商务":
		price = 8
		rate += 1.5
	case "豪华":
		price = 12
		rate += 2.0
	case "SUV":
		price = 5
		rate += 2.5
	}
	log.Println("公里", km, "价格", price, "倍率", rate)
	return rate * (price + float64(parse))
}
